
#pragma string name DStar
#pragma output nostreams


void putpic (int x, int y, int picture);
void MovePiece(char *ptr, char plusx, char plusy);
char TestNextPosIsStop(char nextpos);
char CheckNotFinished(void);
void SetupLevel(void);
void DrawBoard(void);
void Gamekeys(void);

char BallOffset;        /* Ball position */
char BoxOffset;         /* Box position */
char PieceIsBall;       /* 1 = box, 0 = ball */
char Level;             /* Guess! */
char Board[144];        /* Space for decompressed Level */

#define MAXLEVEL 25     /* Highest Level   */
#define STARTLEV  1     /* Start Level */
#define TRUE      1
#define FALSE     0

/* Block numbers.. */
#define WALL 1
#define BUBB 2
#define BALL 3
#define BOX  4


#define K_NEXTLEV '+'
#define K_PREVLEV '-'

#define K_UP       'q'  /* arrow up     */
#define K_DOWN     'a' /* arrow down   */
#define K_LEFT     'o'  /* arrow left   */
#define K_RIGHT    'p'  /* arrow right  */
#define K_SWITCH   'm'  /* Change between blocker/ball */
#define K_EXIT     'g' /* [Esc]/[Quit] */
#define K_CLEAR    'h'

extern unsigned char display[] @12328;
extern unsigned char attr[] @13352;

char levels[]={
       17,30,    //ball offset, box offset
       0x55,0x55,0x55,0x55,
       0x45,0x00,0x00,0x91,
       0x40,0x00,0x02,0x15,
       0x40,0x00,0x58,0x01,
       0x40,0x52,0x00,0x05,
       0x52,0x08,0x00,0x81,
       0x48,0x00,0x25,0x21,
       0x40,0x05,0x80,0x09,
       0x55,0x55,0x55,0x55,
//level2
       30,86,
       0x10,0x44,0x40,0x45,
       0x40,0x80,0x00,0x01,
       0x01,0x81,0x80,0x80,
       0x44,0x80,0x08,0x11,
       0x00,0x04,0x08,0x04,
       0x40,0x11,0x08,0x01,
       0x01,0x04,0x40,0x69,
       0x40,0x00,0x00,0x04,
       0x10,0x40,0x00,0x10,
//level3
       30,46,
       0x55,0x55,0x55,0x55,
       0x40,0x00,0x00,0x91,
       0x40,0x50,0x00,0x51,
       0x40,0x60,0x02,0x01,
       0x48,0x00,0x94,0x09,
       0x46,0x08,0x24,0x25,
       0x45,0x86,0x08,0x95,
       0x60,0x05,0x80,0x01,
       0x55,0x55,0x55,0x55,
//level4
       125,30,
       0x55,0x55,0x55,0x55,
       0x40,0x00,0x00,0x11,
       0x40,0x04,0x00,0x01,
       0x59,0x89,0x99,0x99,
       0x44,0x62,0x44,0x45,
       0x59,0x98,0x99,0x99,
       0x40,0x04,0x00,0x01,
       0x40,0x40,0x00,0x41,
       0x55,0x55,0x55,0x55,
//level5
       17,110,
       0x15,0x55,0x55,0x54,
       0x40,0x40,0x41,0x01,
       0x41,0x84,0x82,0x11,
       0x50,0x00,0x41,0x01,
       0x61,0x90,0x00,0x05,
       0x50,0x01,0x21,0x01,
       0x64,0x11,0x10,0x11,
       0x40,0x40,0x24,0x19,
       0x15,0x55,0x55,0x54,
//level6
       65,113,
       0x00,0x55,0x55,0x55,
       0x01,0x02,0x01,0x89,
       0x04,0x02,0x00,0x45,
       0x10,0x02,0x00,0x01,
       0x40,0x02,0x00,0x01,
       0x50,0x02,0x04,0x05,
       0x40,0x02,0x00,0x41,
       0x41,0x02,0x05,0x81,
       0x55,0x55,0x55,0x55,
//level7
       115,122,
       0x55,0x55,0x55,0x55,
       0x40,0x00,0x00,0x01,
       0x14,0x54,0x18,0x59,
       0x18,0x18,0x44,0x44,
       0x04,0x10,0x54,0x50,
       0x14,0x10,0x64,0x64,
       0x40,0x00,0x00,0x01,
       0x40,0x60,0x00,0x19,
       0x55,0x55,0x55,0x55,
//level8
       108,98,
       0x55,0x55,0x55,0x54,
       0x42,0x50,0x00,0x05,
       0x41,0x81,0x48,0x01,
       0x42,0x51,0x18,0x01,
       0x50,0x01,0x41,0x91,
       0x51,0x00,0x02,0x61,
       0x62,0x40,0x81,0x11,
       0x50,0x00,0x00,0x01,
       0x15,0x55,0x55,0x55,
//level9
       30,72,
       0x04,0x55,0x55,0x54,
       0x19,0x80,0x01,0x01,
       0x62,0x40,0x20,0x04,
       0x11,0x09,0x42,0x41,
       0x41,0x86,0x20,0x09,
       0x40,0x09,0x40,0x04,
       0x66,0x00,0x00,0x10,
       0x40,0x00,0x00,0x40,
       0x55,0x55,0x55,0x00,
//level10
       93,36,
       0x00,0x55,0x55,0x54,
       0x55,0x20,0x00,0x01,
       0x40,0x05,0x62,0x49,
       0x48,0x06,0x18,0x04,
       0x40,0x04,0x20,0x49,
       0x66,0x04,0x90,0x44,
       0x18,0x05,0x41,0x50,
       0x40,0x00,0x04,0x44,
       0x15,0x55,0x50,0x41,
//level11
       30,108,
       0x55,0x55,0x55,0x55,
       0x40,0x01,0x00,0x01,
       0x41,0xA0,0x02,0x85,
       0x50,0x20,0x14,0x09,
       0x60,0x06,0x68,0x15,
       0x51,0x40,0x14,0x01,
       0x60,0x92,0x00,0x09,
       0x59,0x50,0x04,0x05,
       0x14,0x55,0x55,0x54,
//level12
       17,92,
       0x50,0x01,0x41,0x54,
       0x45,0x56,0x15,0x25,
       0x40,0x28,0x00,0x81,
       0x45,0x05,0x81,0x91,
       0x44,0x85,0x61,0x41,
       0x45,0x05,0x01,0x11,
       0x40,0x08,0x00,0x01,
       0x40,0x00,0x20,0x01,
       0x55,0x55,0x55,0x55,
//level13
       18,113,
       0x15,0x55,0x55,0x54,
       0x41,0x00,0x00,0x85,
       0x44,0x06,0x02,0x51,
       0x40,0x00,0x80,0x11,
       0x48,0x00,0x00,0x19,
       0x44,0x00,0x20,0x01,
       0x50,0x00,0x88,0x19,
       0x40,0x40,0x21,0x11,
       0x15,0x55,0x55,0x54,
//level14
       36,50,
       0x55,0x55,0x55,0x55,
       0x66,0x00,0x00,0x99,
       0x49,0x00,0x01,0x41,
       0x40,0x00,0x02,0x01,
       0x40,0x00,0x24,0x01,
       0x40,0x02,0x00,0x01,
       0x49,0x00,0x00,0x41,
       0x66,0x00,0x00,0x99,
       0x55,0x55,0x55,0x55,
//level15
       51,76,
       0x15,0x54,0x55,0x54,
       0x40,0x09,0x00,0x21,
       0x44,0x84,0x10,0x21,
       0x40,0x40,0x68,0x61,
       0x11,0x01,0x20,0x11,
       0x60,0x00,0x10,0x61,
       0x10,0x00,0x80,0x04,
       0x60,0x00,0x00,0x09,
       0x15,0x55,0x55,0x54,
//level16
       35,19,
       0x55,0x55,0x55,0x55,
       0x50,0x62,0x00,0x09,
       0x60,0x98,0x00,0x05,
       0x51,0x50,0x08,0x05,
       0x50,0x02,0x64,0x01,
       0x68,0x00,0x09,0x81,
       0x52,0x00,0x55,0x81,
       0x59,0x04,0x00,0x01,
       0x55,0x55,0x55,0x55,
//level17
       29,124,
       0x55,0x55,0x55,0x55,
       0x49,0x00,0x00,0x41,
       0x44,0x26,0x98,0x11,
       0x40,0x19,0x64,0x81,
       0x49,0x00,0x02,0x41,
       0x42,0x60,0x09,0x01,
       0x44,0x11,0x64,0x11,
       0x40,0x21,0x80,0x01,
       0x55,0x55,0x55,0x55,
//level18
       115,26,
       0x55,0x55,0x55,0x55,
       0x48,0x02,0x01,0x01,
       0x41,0x98,0x06,0x01,
       0x40,0x64,0x01,0x81,
       0x40,0x81,0x02,0x61,
       0x46,0x40,0x49,0x01,
       0x49,0x84,0x84,0x01,
       0x64,0x04,0x00,0x41,
       0x55,0x55,0x55,0x55,
//level19
       126,110,
       0x55,0x55,0x55,0x55,
       0x60,0x14,0x00,0x59,
       0x44,0x10,0x00,0x61,
       0x49,0x02,0x50,0x81,
       0x44,0x01,0x80,0x01,
       0x40,0x10,0x24,0x01,
       0x45,0x24,0x58,0x11,
       0x49,0x18,0x00,0x51,
       0x55,0x55,0x55,0x55,
//level20
       77,66,
       0x55,0x55,0x55,0x55,
       0x40,0x98,0x00,0x01,
       0x58,0x24,0x58,0x05,
       0x44,0x48,0x04,0x11,
       0x40,0x41,0x41,0x09,
       0x44,0x10,0x21,0x11,
       0x50,0x25,0x18,0x25,
       0x40,0x00,0x26,0x01,
       0x55,0x55,0x55,0x55,
//level21
       103,105,
       0x55,0x55,0x55,0x55,
       0x45,0x40,0x08,0x05,
       0x40,0x40,0x00,0x45,
       0x40,0x58,0x00,0x21,
       0x42,0x00,0x80,0x85,
       0x40,0x10,0x05,0x61,
       0x42,0x20,0x02,0x29,
       0x55,0x55,0x55,0x55,
       0x00,0x00,0x00,0x00,
//level22
       103,105,
       0x55,0x55,0x55,0x55,
       0x64,0x19,0x18,0x11,
       0x40,0x10,0x00,0x01,
       0x60,0x10,0x60,0x81,
       0x51,0x80,0x02,0x15,
       0x48,0x40,0x56,0x01,
       0x40,0x04,0x40,0x81,
       0x55,0x55,0x55,0x55,
       0x00,0x00,0x00,0x00,
//level23
       103,105,
       0x15,0x55,0x55,0x54,
       0x44,0x19,0x18,0x11,
       0x40,0x20,0x40,0x01,
       0x50,0x10,0x21,0x81,
       0x41,0x81,0x0A,0x21,
       0x58,0x40,0x52,0x01,
       0x40,0x04,0x40,0x81,
       0x15,0x55,0x55,0x54,
       0x00,0x00,0x00,0x00,
//level24
       103,105,
       0x55,0x55,0x55,0x55,
       0x40,0x04,0x00,0x05,
       0x45,0x88,0x01,0x65,
       0x46,0x00,0x24,0x15,
       0x42,0x09,0x14,0x01,
       0x46,0x21,0x00,0x51,
       0x45,0x00,0x45,0x69,
       0x55,0x55,0x55,0x55,
       0x00,0x00,0x00,0x00,
//level25
       103,105,
       0x55,0x55,0x55,0x55,
       0x40,0x00,0x00,0x11,
       0x48,0x58,0x08,0x01,
       0x40,0x60,0x81,0x41,
       0x48,0x01,0x41,0x81,
       0x46,0x02,0x40,0x21,
       0x45,0x84,0x00,0x01,
       0x55,0x55,0x55,0x55,
       0x00,0x00,0x00,0x00
};


